from zope.interface import Interface


"""
server -> watch protocols
watch protocol -> watch
watch -> branches
branch -> execute path
execute path -> actions
(action set run by transaction)
execute path -> path forks
path forks -> branches
execute path -> decisions
decision -> branch
"""


### interface for watch and children ###

class IWatch(Interface):
    """watches are the primary piece of functionality for this package"""
    def run():
        """use 
           iq = InputQueue(self.config.inputqueue)
           try:
              iq.open()
                while (iq.read()):
                    do
                    break
        """


class IBranch(Interface):
    """branches belong to watches"""

class IExecutePath(Interface):
    """execute paths define the course of actions and transactions
       to be run within a branch
    """

class ITransaction(Interface):
    """takes a set of action and attempts to perform them
       raising for any inability to complete
    """

class IDecision(Interface):
    """a simple set of if-elsif-else type logic steps"""

class ICondition(Interface):
    """the actual if/elsif match set for a decision"""


class ITestBehavior(Interface):
    """a behavior to be used by specific conditions on test"""


class IAction(Interface):
    """single actionable processess, owned by ExecutePath, 
       operated on by transaction
    """

class IRunBehavior(Interface):
    """a behavior defined to allow actions to implement action.run() 
       as generically as possible
    """

class IWorkItem(Interface):
    """an item representing a workable unit, such as a file, binary image, 
       serialized data, xml stream, etc
    """
    

### interfaces for inputqueue module"""

class IOpenBehavior(Interface):
    """implements some kind of open behavior for InputQueue.
       expects __call__ to be overridden.
    """

class IReadBehavior(Interface):
    """implements some kind of read behavior for InputQueue.
       expects __call__ to be overridden.
    """

class ICloseBehavior(Interface):
    """implements some kind of close behavior for InputQueue.
       expects __call__ to be overridden.
    """

class IInputQueue(Interface):
    """Input Queue, like a Folder, Web Service, etc"""
    def open():
        """should implement IOpenBehavior"""
        pass
    def read():
        """should implement IReadBehavior"""
        pass
    def close():
        """should implement ICloseBehavior"""
        pass

### interfaces for watcher.scheduler ###

class ISchedulerTime(Interface):
    """date/time determined by an xml config"""

class IWatchSchedule(Interface):
    """watch scheduler.  takes start/stop times"""
    def start_time(t):
        """t should be an ISchedulerTime"""
        pass
    def stop_time(t):
        """t should be an ISchedulerTime"""
        pass

class IWatchScheduler(Interface):
    """should be subscribed to by all Watches objects.
       in our case, a "state" change of the WatchScheduler will be triggered
       by a match condition on the watch_schedule for all of it's assigned
       watches.
    """
    def subscribe(obj):
        """should have Watch objects subscribe to it"""
        pass

    def unsubscribe(obj):
        """unsubscribe should the watch be removed entirely"""
        pass

    def notify(event):
        """notify the relevant subscribers of an event"""
        pass

### interfaces for config module ###

class IConfigLoader(Interface):
    """loads a config from a given filename, and returns the amara doc"""

class IKlassBuilder(Interface):
    """builds a class based on a config generated by IConfigLoader"""


### interface for watcher object and container base class ###

class IWatcherObject(Interface):
    """calls config loader against a particular configname to load itself"""

class IWatcherContainer(Interface):
    """provides standard parent/child awareness"""
